package br.senai.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import sun.misc.BASE64Encoder;

public class Criptografia {
	private MessageDigest messageDigest;
	private BASE64Encoder encoder;
	
	public String encrypt(String value) throws NoSuchAlgorithmException {
		messageDigest = MessageDigest.getInstance("SHA-256");

		encoder = new BASE64Encoder();
		
		byte[] hash = messageDigest.digest(value.getBytes());
		
		return encoder.encode(hash);
	}

}
